﻿
import { Router, Route, IndexRedirect, hashHistory } from 'react-router';

import { syncHistoryWithStore } from 'react-router-redux';
import { Provider } from 'react-redux'
import React from 'react';
import ReactDOM from 'react-dom';


import Access from './js/pages/access';
import Login from './js/pages/access/login';
import Register from './js/pages/access/register';
import RegForm from './js/pages/access/reg-form';
import RegSpecForm from './js/pages/access/reg-spec-form';
import MailResetPass from './js/pages/access/mail-reset-pass';
import SmsResetPass from './js/pages/access/sms-reset-pass';
import Board from './js/pages/dashboard';
import Images from './js/pages/dashboard/images';
import ImageAdd from './js/pages/dashboard/image-add';
import Patients from './js/pages/dashboard/patients';
import PatientAdd from './js/pages/dashboard/patient-add';
import PatientEdit from './js/pages/dashboard/patient-edit';
import PatientDetail from './js/pages/dashboard/patient-detail';
import User from './js/pages/dashboard/user';

import Admin from './js/pages/admin';
import Examine from './js/pages/admin/examine';
import ExamineDetail from './js/pages/admin/examine-detail';
import UserList from './js/pages/admin/user-list';
import UserAdd from './js/pages/admin/user-add';
import UserEdit from './js/pages/admin/user-edit';
import RoleList from './js/pages/admin/role-list';
import RoleAdd from './js/pages/admin/role-add';
import RoleEdit from './js/pages/admin/role-edit';
import SpecialistList from './js/pages/admin/specialist-list';
import SpecialistListUnpass from './js/pages/admin/specialist-list-unpass';
import SpecialistAdd from './js/pages/admin/specialist-add';
import SpecialistEdit from './js/pages/admin/specialist-edit';
import SpecialistDetail from './js/pages/admin/specialist-detail';
import DataDictionaryList from './js/pages/admin/data-dictionary-list';
import AdminList from './js/pages/admin/admin-list';
import AdminAdd from './js/pages/admin/admin-add';
import AdminEdit from './js/pages/admin/admin-edit';
import SystemSetting from './js/pages/admin/system-setting'
import LoggerManage from './js/pages/admin/logger-manage'
import ConsultManage from './js/pages/admin/consult-manage'
import OrderManage from './js/pages/admin/order-manage'
import TemplateManage from './js/pages/admin/template-manage'
import AppManage from './js/pages/admin/app-manage'
import PublicApp from './js/pages/admin/app-public'
import MessageManage from './js/pages/admin/message-manage'
import SuggestManage from './js/pages/admin/suggest-manage'
import Chargetype from  './js/pages/admin/chargetype';
import CheckType from  './js/pages/admin/checktype';
import Criticality from  './js/pages/admin/criticality';
import Gender from  './js/pages/admin/gender';
import Modality from  './js/pages/admin/modality';
import Nationality from  './js/pages/admin/nationality';
import PatientType from  './js/pages/admin/patienttype';
import TestResult from  './js/pages/admin/testresult';
import Title from  './js/pages/admin/title';
import IdType from  './js/pages/admin/idtype';
import Region from  './js/pages/admin/region';
import Action from  './js/pages/admin/action';
import Role from  './js/pages/admin/role';
import Department from  './js/pages/admin/department';
import ProductType from  './js/pages/admin/producttype';
import Product from  './js/pages/admin/product';
import SpecialistProduct from  './js/pages/admin/specialist-product';
import MyProduct from  './js/pages/specialist/my-product';

import Specialist from './js/pages/specialist'
import WorkBoard from './js/pages/specialist/work-board'
import SubscribeList from './js/pages/specialist/subscribe-list'
import DiagnoseRecords from './js/pages/specialist/diagnose-records'
import SpecUser from './js/pages/specialist/spec-user'

import configStore from './js/store/index';
const store = configStore();
const history = syncHistoryWithStore(hashHistory,store);

require('antd/dist/antd.min.css');
require('./css/antd-custom-style.css');
class MainApp extends React.Component{
	constructor(props){
		super(props);
		this.state = {};
	}
	render(){
		return (
			<div className="wrap">
				{this.props.children}
			</div>
		)
	}
}
let root = document.createElement('div');
document.body.appendChild(root);
ReactDOM.render((
  <Provider store={store}>
    <Router history={history}>
      <Route path="/" component={MainApp}>
        <IndexRedirect to="/login" />
        <Route path="/" component={Access}>
          <Route path="/login" component={Login} />
          <Route path="/register" component={Register} />
          <Route path="/reg-form" component={RegForm} />
          <Route path="/reg-spec-form" component={RegSpecForm} />
          <Route path="/mail-reset-pass" component={MailResetPass} />
          <Route path="/sms-reset-pass" component={SmsResetPass} />
        </Route>
				<Route component={Board}>
					<Route path="/images" component={Images} />
					<Route path="/image-add" component={ImageAdd} />
					<Route path="/patients" component={Patients} />
					<Route path="/patient-add" component={PatientAdd} />
					<Route path="/patient-edit/:id" component={PatientEdit} />
					<Route path="/patient-detail/:id" component={PatientDetail} />
					<Route path="/user" component={User} />
				</Route>
				<Route component={Admin}>
					<Route path="/_admin" component={Examine} />
					<Route path="/examine-detail/:id" component={ExamineDetail} />
					<Route path="/user-list" component={UserList} />
					<Route path="/user-add" component={UserAdd} />
					<Route path="/user-edit/:id" component={UserEdit} />
					<Route path="/admin-list" component={AdminList} />
					<Route path="/admin-add" component={AdminAdd} />
					<Route path="/admin-edit/:id" component={AdminEdit} />
					<Route path="/role-list" component={RoleList} />
					<Route path="/role-add" component={RoleAdd} />
					<Route path="/role-edit/:id" component={RoleEdit} />
					<Route path="/specialist-list" component={SpecialistList} />
					<Route path="/specialist-listunpass" component={SpecialistListUnpass} />
					<Route path="/specialist-add" component={SpecialistAdd} />
					<Route path="/specialist-edit/:id" component={SpecialistEdit} />
					<Route path="/specialist-detail/:id" component={SpecialistDetail} />
					<Route path="/data-dictionary-list/:id" component={DataDictionaryList} />
					<Route path="/system-setting" component={SystemSetting} />
					<Route path="/logger-manage" component={LoggerManage} />
					<Route path="/consult-manage" component={ConsultManage} />
					<Route path="/order-manage" component={OrderManage} />
					<Route path="/template-manage" component={TemplateManage} />
					<Route path="/app-manage" component={AppManage} />
					<Route path="/app-public" component={PublicApp} />
					<Route path="/message-manage" component={MessageManage} />
					<Route path="/suggest-manage" component={SuggestManage} />
					<Route path="/chargetype" component={Chargetype}/>
					<Route path="/checktype" component={CheckType}/>
					<Route path="/criticality" component={Criticality}/>
					<Route path="/gender" component={Gender}/>
					<Route path="/modality" component={Modality}/>
					<Route path="/nationality" component={Nationality}/>
					<Route path="/patienttype" component={PatientType}/>
					<Route path="/testresult" component={TestResult}/>
					<Route path="/title" component={Title}/>
					<Route path="/idtype" component={IdType}/>
					<Route path="/region" component={Region}/>
					<Route path="/action" component={Action}/>
					<Route path="/role" component={Role}/>
					<Route path="/department" component={Department}/>
					<Route path="/producttype" component={ProductType}/>
					<Route path="/product" component={Product}/>
					<Route path="/specialist-product" component={SpecialistProduct}/>
				</Route>
	      <Route component={Specialist}>
		      <Route path="/work-board" component={WorkBoard}/>
		      <Route path="/subscribe-list" component={SubscribeList}/>
		      <Route path="/diagnose-records" component={DiagnoseRecords}/>
		      <Route path="/specUser" component={SpecUser} />
			  <Route path="/my-product" component={MyProduct}/>
	      </Route>
			</Route>
		</Router>
	</Provider>
),root);
